import "./index.css";
import { listQuestionBankVoByPageUsingPost } from "@/api/questionBankController";
import { Flex, message } from "antd";
import Title from "antd/es/typography/Title";
import QuestionBankList from "@/components/QuestionBankList";

export const dynamic = "force-dynamic";

export default async function Banks() {
  let questionBankList = [];

  // 获取题库列表
  try {
    const res = await listQuestionBankVoByPageUsingPost({
      pageSize: 200, // 获取200条数据（最多）
      sortField: "createTime",
      sortOrder: "desc",
    });
    questionBankList = res?.data?.records || [];
  } catch (e) {
    message.error("获取题库列表失败" + e.message);
  }

  return (
    <div id={"homePage"} className={"limit-width"}>
      <Flex vertical>
        <Flex>
          <Title level={3}>面试题库</Title>
        </Flex>
        <QuestionBankList questionBankList={questionBankList} />
      </Flex>
    </div>
  );
}
